﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using DownloadInterface;
using System.Windows.Media.Imaging;
using System.Windows.Media;

namespace WpfApplication2
{
    [ValueConversion(typeof(FileType),typeof(ImageSource))]
    public class ImageConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FileType fileType = (FileType)value;
            Uri uri;
            BitmapImage bimg;
            switch (fileType)
            {
                case FileType.FILE_DOCUMENT: 
                    uri = new Uri("/WpfApplication2;component/Images/document.png", UriKind.Relative);
                    break;
                case FileType.FILE_MUSIC: 
                    uri = new Uri("/WpfApplication2;component/Images/music.png", UriKind.Relative);
                    break;
                case FileType.FILE_MOVIE: 
                    uri = new Uri("/WpfApplication2;component/Images/movie.png", UriKind.Relative);
                    break;
                case FileType.FILE_EXECUTEABLE: 
                    uri = new Uri("/WpfApplication2;component/Images/program.png", UriKind.Relative);
                    break;
                default: 
                    uri = new Uri("/WpfApplication2;component/Images/unknown.png", UriKind.Relative);
                    break; 
            }
           // return 
          //  return new ImageSource();
           return  new BitmapImage(uri);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
